package com.cykj.utils;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

/**
 * @author 王宇
 * @CreateTime: 2025-07-09  09:25
 * @BelongsProject: jd_seckill
 * @BelongsPackage: com.cykj.util
 * @description 密码加密工具类
 */
public class MD5Util {
    /**
     * @Description 密码加密
     * @param password
     * @return java.lang.String
     */
    public static String encrypt(String password) {
        try {
            MessageDigest md = MessageDigest.getInstance("MD5");
            byte[] digest = md.digest(password.getBytes());
            StringBuilder sb = new StringBuilder();
            for (byte b : digest) {
                sb.append(String.format("%02x", b & 0xff));
            }
            return sb.toString();
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
            return null;
        }
    }
}
